package com.jingan.nursinghome.regulatory.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.util.AttributeSet;

import cn.android.support.v7.lib.sin.crown.base.BaseView;
import cn.android.support.v7.lib.sin.crown.utils.AssetsUtils;
import cn.android.support.v7.lib.sin.crown.utils.ProportionUtils;

/**
 * Created by 彭治铭 on 2017/10/24.
 */

public class AddView extends BaseView {
    public AddView(Context context) {
        super(context);
        init();
    }

    public AddView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    Bitmap bitmap;

    void init() {
        bitmap = AssetsUtils.getInstance().getBitmapFromAssets( "图标/添加.png", 0, true);
        bitmap = ProportionUtils.getInstance().adapterBitmap(bitmap);
    }

    int widht= ProportionUtils.getInstance().adapterInt(720);
    int height = ProportionUtils.getInstance().adapterInt(240);

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        //super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        setMeasuredDimension(widht, height);
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        canvas.drawColor(Color.WHITE);
        int x=(widht - bitmap.getWidth())/2;
        canvas.drawBitmap(bitmap, x, (getHeight() - bitmap.getHeight()) / 2, paint);
    }
}
